WebStorage

interface WebStorage

An HTML WebStorage.

Provides access to the session storage or local storage for a particular document on the loaded web page. Allows you to add, modify, or delete the stored items.

Since

7.1

Properties

Link copied to clipboard

The number of key/value pairs in the storage.

Functions

Link copied to clipboard
abstract fun clear()
Removes all the items from the storage.
Link copied to clipboard
abstract fun contains(key: String): Boolean
Returns true if the storage contains an item with the specified key, otherwise false.
Link copied to clipboard
operator fun WebStorage.get(key: String): String?
operator fun WebStorage.get(key: String): String?

Returns the value associated with the given key if it exists in the storage.

Link copied to clipboard
abstract fun item(key: String): Optional<String>
Returns an Optional that contains the value associated with the given key if it exists in the storage, otherwise an empty Optional.
Link copied to clipboard
abstract fun key(index: Int): Optional<String>
Returns an Optional that contains the name of the key by the specified index if it exists in the storage, otherwise an empty Optional.
Link copied to clipboard
abstract fun length(): Int
Returns the number of key/value pairs in the storage.
Link copied to clipboard
abstract fun putItem(key: String, value: String)
Adds the item with the specified key and value to the storage, or updates it if the item with the given key already exists.
Link copied to clipboard
abstract fun removeItem(key: String)
Removes the item with the specified key from the storage.
Link copied to clipboard
operator fun WebStorage.set(key: String, value: String)
operator fun WebStorage.set(key: String, value: String)

Adds the item with the specified key and value to the storage, or updates it if the item with the given key already exists.